# Replicate scaling of nine EP-manifestos with wordfish 
library(tm)

# Directory where pre-processed manifestos reside
directory <- "puretxt"
#Read as Corpus
textcorpus <- Corpus(DirSource(directory),readerControl = list(reader=readPlain,language = "de", load = FALSE))

# Copy and strip numbers (copying not strictly necessary )
text.corpus.format<-textcorpus
text.corpus.format <-  tm_map(text.corpus.format,removeNumbers)

# Form Matrix. Documentation is out-dated (setting of rownames + transposition not longer required)
wordfreqmatrix <-  TermDocumentMatrix(text.corpus.format)
wcdata<-as.matrix(wordfreqmatrix)


#Estimate!
source("wordfish_1.3.r")
results<-wordfish(input=wcdata,dir=c(6,7),writeout=TRUE,boot=TRUE)













































